<?php

/**
 * Mailing filter form.
 *
 * @package    Sanitas
 * @subpackage filter
 * @author     Jose Antonio Sánchez Bedoya
 * @version    SVN: $Id: sfDoctrineFormFilterTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class MailingFormFilter extends BaseMailingFormFilter
{
  public function configure()
  {
      $this->disableLocalCSRFProtection();
      //following code will remove fields from form
      unset($this->widgetSchema['created_at']);
      unset($this->widgetSchema['updated_at']);
      unset($this->widgetSchema['validated_at']);
      unset($this->widgetSchema['is_validated']);
      unset($this->widgetSchema['removed_at']);
      unset($this->widgetSchema['remove_it']);
             

      $this->setWidget('asunto', new sfWidgetFormFilterInput(array('with_empty' => false)));
      $this->setWidget('texto', new sfWidgetFormFilterInput(array('with_empty' => false)));
      
      // Rango de fechas creacion
      $from_date = new sfWidgetFormJQueryDate(array('culture' => sfContext::getInstance()->getUser()->getCulture(),'image' => '/images/calendar.gif',));
      $from_date->getOption('date_widget')->setOption('format', '%day%/%month%/%year%');
      $to_date = new sfWidgetFormJQueryDate(array('culture' => sfContext::getInstance()->getUser()->getCulture(),'image' => '/images/calendar.gif',));
      $to_date->getOption('date_widget')->setOption('format', '%day%/%month%/%year%');
      $this->widgetSchema['fecha_creacion'] = new sfWidgetFormFilterDate(array(
  			'from_date' => $from_date, 
  			'to_date' => $to_date, 
  			'with_empty' => false,
  	));
      // Rango de fechas lanzamiento
      $from_date1 = new sfWidgetFormJQueryDate(array('culture' => sfContext::getInstance()->getUser()->getCulture(),'image' => '/images/calendar.gif',));
      $from_date1->getOption('date_widget')->setOption('format', '%day%/%month%/%year%');
      $to_date1 = new sfWidgetFormJQueryDate(array('culture' => sfContext::getInstance()->getUser()->getCulture(),'image' => '/images/calendar.gif',));
      $to_date1->getOption('date_widget')->setOption('format', '%day%/%month%/%year%');
      $this->widgetSchema['fecha_lanzamiento'] = new sfWidgetFormFilterDate(array(
  			'from_date' => $from_date1, 
  			'to_date' => $to_date1, 
  			'with_empty' => false,
  	));
      
  }
  
   public function getFields()
  {
    return array(
      'id'                => 'Number',
      'asunto'            => 'Text',
      'texto'             => 'Text',
      'fecha_creacion'    => 'Date',
      'fecha_lanzamiento' => 'Date',
      'grupo_id'          => 'ForeignKey',
      'adjunto1'          => 'Text',
      'adjunto2'          => 'Text',
      'created_at'        => 'Date',
      'updated_at'        => 'Date',
      'validated_at'      => 'Date',
      'is_validated'      => 'Boolean',
      'removed_at'        => 'Date',
      'remove_it'         => 'Boolean',
    );
  }
}
